<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['province']=file_get_contents('core/resource/area.txt');
	$return['province']=unserialize($return['province']);
	$return['pcd']=array(
		'province' =>trim($_RQ['province']),
		'city' =>trim($_RQ['city']),
		'district' =>trim($_RQ['district']),
	);
	//exi(2,'error');
	$history=pdo_getall('jy_mapfuwu_history',array('uid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'','','createtime desc');
	$return['history']=$history;
	
	$return['start']=$_RQ['start'];
	exi($return);
}
if($_RQ['op']=='select_area'){
	$return['province']=file_get_contents('core/resource/area.txt');
	$return['province']=unserialize($return['province']);
	$return['pcd']=array(
		'province' =>trim($_RQ['province']),
		'city' =>trim($_RQ['city']),
		'district' =>trim($_RQ['district']),
	);
	
	exi($return);
}
if($_RQ['op']=='history'){
	$post=get_postdata();
	$address=pdo_get('jy_mapfuwu_history',array('uid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid'],'address'=>$post['address']));
	if($address){
		pdo_update('jy_mapfuwu_history',array('createtime'=>TIMESTAMP),array('id'=>$address['id']));
	}else{
		$data=array('uniacid'=>$_SESSION['uniacid'],'uid'=>$_SESSION['uid'],'createtime'=>TIMESTAMP,'address'=>$post['address'],'pcd'=>$post['pcd']);
		pdo_insert('jy_mapfuwu_history',$data);
	}
	exi('success');
}
?>